/**
 *  Copyright (c) 2017-2022 Rushang Co.Ltd All Rights Reserved.
 */
package com.rshang.rsdp.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.rshang.rsdp.bean.Response;
import com.rshang.rsdp.service.ITbUserService;

/**
 * 功能简介：系统主控制器<br/>
 * @author zhangjun
 * @create 2017年7月19日下午4:01:54
 * 
 */
@Controller
public class IndexController extends BaseController{

	
	@Autowired
	ITbUserService userService;
	
	/**
	 * 系统登陆
	 */
	@RequestMapping("/login")
	@ResponseBody
	public Response login(HttpServletRequest request){
		return userService.userLogin(request);
	}
	
	@RequiresAuthentication
	@RequestMapping("/editInfo/save")
	@ResponseBody
	public Response editInfoSave(){
		return userService.myEditSave(request,this.getSessionUser().getUserId());
	}
	
	/*private void initTestData(){
		//添加系统管理员
		TbUser user = new TbUser();
	    user.setUserName("admin");
	    user.setUserXm("系统管理员");
	    user.setUserPass(md5());
	    user.setUserPhone("13000000000");
	    user.setUserEmail("admin@rshang.com");
	    userService.insert(user);*/

		//添加用户角色
		/*TbRole role = new TbRole();
		role.setRoleId(String.valueOf(IdWorker.getId()));
	    role.setRoleName("管理员");
	    role.setLrr("362042d1dea147faaa5589531c97af08");
	    role.setXgr("362042d1dea147faaa5589531c97af08");
	    roleService.insert(role);
	    
	    role = new TbRole();
	    role.setRoleId(String.valueOf(IdWorker.getId()));
	    role.setRoleName("部门经理");
	    role.setLrr("362042d1dea147faaa5589531c97af08");
	    role.setXgr("362042d1dea147faaa5589531c97af08");
	    roleService.insert(role);
	    
	    role = new TbRole();
	    role.setRoleId(String.valueOf(IdWorker.getId()));
	    role.setRoleName("普通员工");
	    role.setLrr("362042d1dea147faaa5589531c97af08");
	    role.setXgr("362042d1dea147faaa5589531c97af08");
	    roleService.insert(role);*/
		
		/*TbAuth auth = new TbAuth();
		auth.setAuthPid(0);
		auth.setAuthName("待办查询");
		auth.setAuthType("M");
		auth.setAuthUrl("#");
		auth.setAuthOrder("10");
		auth.setLrr("362042d1dea147faaa5589531c97af08");
		auth.setXgr("362042d1dea147faaa5589531c97af08");
		authService.insert(auth);
		
		auth = new TbAuth();
		auth.setAuthPid(0);
		auth.setAuthName("人事代理信息");
		auth.setAuthType("M");
		auth.setAuthUrl("#");
		auth.setAuthOrder("20");
		auth.setLrr("362042d1dea147faaa5589531c97af08");
		auth.setXgr("362042d1dea147faaa5589531c97af08");
		authService.insert(auth);
		
		auth = new TbAuth();
		auth.setAuthPid(0);
		auth.setAuthName("系统管理");
		auth.setAuthType("M");
		auth.setAuthUrl("#");
		auth.setAuthOrder("30");
		auth.setLrr("362042d1dea147faaa5589531c97af08");
		auth.setXgr("362042d1dea147faaa5589531c97af08");
		authService.insert(auth);
		
		TbAuth auth = new TbAuth();
		auth.setAuthPid(1);
		auth.setAuthName("离职查询");
		auth.setAuthType("A");
		auth.setAuthUrl("/dbrw/lzcx");
		auth.setAuthOrder("10");
		auth.setLrr("362042d1dea147faaa5589531c97af08");
		auth.setXgr("362042d1dea147faaa5589531c97af08");
		authService.insert(auth);
		
		auth = new TbAuth();
		auth.setAuthPid(1);
		auth.setAuthName("未办查询");
		auth.setAuthType("A");
		auth.setAuthUrl("/dbrw/wbcx");
		auth.setAuthOrder("20");
		auth.setLrr("362042d1dea147faaa5589531c97af08");
		auth.setXgr("362042d1dea147faaa5589531c97af08");
		authService.insert(auth);
		
		auth = new TbAuth();
		auth.setAuthPid(2);
		auth.setAuthName("基本信息");
		auth.setAuthType("A");
		auth.setAuthUrl("/htxx/jbxx");
		auth.setAuthOrder("10");
		auth.setLrr("362042d1dea147faaa5589531c97af08");
		auth.setXgr("362042d1dea147faaa5589531c97af08");
		authService.insert(auth);
		
		auth = new TbAuth();
		auth.setAuthPid(2);
		auth.setAuthName("社保信息");
		auth.setAuthType("A");
		auth.setAuthUrl("/htxx/sbxx");
		auth.setAuthOrder("20");
		auth.setLrr("362042d1dea147faaa5589531c97af08");
		auth.setXgr("362042d1dea147faaa5589531c97af08");
		authService.insert(auth);
		
		auth = new TbAuth();
		auth.setAuthPid(2);
		auth.setAuthName("数据调整记录");
		auth.setAuthType("A");
		auth.setAuthUrl("/htxx/tzxx");
		auth.setAuthOrder("30");
		auth.setLrr("362042d1dea147faaa5589531c97af08");
		auth.setXgr("362042d1dea147faaa5589531c97af08");
		authService.insert(auth);
		
		auth = new TbAuth();
		auth.setAuthPid(3);
		auth.setAuthName("用户管理");
		auth.setAuthType("A");
		auth.setAuthUrl("/system/user");
		auth.setAuthOrder("10");
		auth.setLrr("362042d1dea147faaa5589531c97af08");
		auth.setXgr("362042d1dea147faaa5589531c97af08");
		authService.insert(auth);
		
		auth = new TbAuth();
		auth.setAuthPid(3);
		auth.setAuthName("数据字典");
		auth.setAuthType("A");
		auth.setAuthUrl("/system/sjzd");
		auth.setAuthOrder("20");
		auth.setLrr("362042d1dea147faaa5589531c97af08");
		auth.setXgr("362042d1dea147faaa5589531c97af08");
		authService.insert(auth);*/
		
		/*TbUserrole userrole = new TbUserrole();
		userrole.setUserId("362042d1dea147faaa5589531c97af08");
		userrole.setRoleId("888289995578712066");
		userRoleService.insert(userrole);
		
		TbRoleauth roleAuth = new TbRoleauth();
		roleAuth.setRoleId("888289995578712066");
		roleAuth.setAuthId(3);
		roleAuthService.insert(roleAuth);
		
		roleAuth = new TbRoleauth();
		roleAuth.setRoleId("888289995578712066");
		roleAuth.setAuthId(9);
		roleAuthService.insert(roleAuth);
		
		roleAuth = new TbRoleauth();
		roleAuth.setRoleId("888289995578712066");
		roleAuth.setAuthId(10);
		roleAuthService.insert(roleAuth);
	}*/
	
	
}
